﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraBehavior : MonoBehaviour
{
    public static float pixelsToUnits = 1f;
    public static float scale = 1f;
    public static Vector2 nativeResolution = new Vector2(2248, 1080);

    //像素完美
    void PixelPerfect() 
    {
        var camera = GetComponent<Camera>();
        if (camera.orthographic)
        {
            scale = Screen.height / nativeResolution.y;
            pixelsToUnits *= scale;
            camera.orthographicSize = (Screen.height / 2f) / pixelsToUnits;
        }
    }

    private void Awake()
    {
        PixelPerfect();
    }
    

    // Update is called once per frame
    void Update()
    {
        
    }
}
